import Vue from 'vue';
import Router from 'vue-router';
import hooks from './hooks';
import HomeRouter from './home';
import InfoIdentityRouter from './information/identity';
import InfoPersonalInformationRouter from './information/personal';
import InfoWorkInformationRouter from './information/work';
import InfoContactInformationRouter from './information/contact';
import InfoAdditionalRouter from './information/additional';
// import LoanRouter from './loan';
import AgreemenPrivacyRouter from './agreement/privacy';
import AgreemenRegisterRouter from './agreement/register';
// import OrderDetailsRouter from './orderDetails';
import RepayRouter from './repay';
import HelpRouter from './help';
import HelpRepaySkyRouter from './help/repaySky';
import HelpRepayMspRouter from './help/repayMsp';
import HelpRepayappRouter from './help/repayapp';
import HelpRepaymlRouter from './help/repayml';
import HelpRepaypartnerRouter from './help/repaypartner';
import HelpGetmoneyRouter from './help/getmoney';
import HelpReviewtimeRouter from './help/reviewtime';
import HelpLoanproblemRouter from './help/loanproblem';
import HelpRepayecpayRouter from './help/repayecpay';
import HelpMspRepaymlRouter from './help/msp/repayml';
import HelpMspRepayrdRouter from './help/msp/repayrd';
import HelpMspRepayecpayRouter from './help/msp/repayecpay';
import HelpMspRepayappRouter from './help/msp/repayapp';
import HelpMspGetmoneyRouter from './help/msp/getmoney';
import HelpMspGetmoneyMlRouter from './help/msp/getmoneyMl';
import HelpMspGetmoneyRdRouter from './help/msp/getmoneyRd';
import HelpQuestionRouter from './help/question';
import AboutRouter from './about';
import AccountRouter from './account';
import ExtensionApplyRouter from './extension/apply';
import ExtensionApplySuccessRouter from './extension/applySuccess';
import ExtensionHistoryRouter from './extension/history';
import ExtensionDetailsRouter from './extension/details';
// import CouponListRouter from './coupon-list';
import PagesRouter from './pages';
import Login from './login';
import utils from '../libs/utils';
import OrderDetailInfo from './orderDetailInfo';
import AddOrder from './addorder';
import Product from './product'
import addOrderState from './addorderState';
import faceCheckMode from './faceCheckMode'
import doubleDanEvent from './doubleDanEvent'

const { generateRandom } = utils;
let routes = [
  {
    path: '/',
    name: 'home-page',
    component: resolve => require(['../views/home'], resolve),
    meta: {
      title: 'MoreGold',
      requiresAuth: false,
    },
  },
  ...faceCheckMode,
  ...addOrderState,
  ...Product,
  ...AddOrder,
  ...HomeRouter,
  ...InfoIdentityRouter,
  ...InfoPersonalInformationRouter,
  ...InfoWorkInformationRouter,
  ...InfoContactInformationRouter,
  ...InfoAdditionalRouter,
  // ...LoanRouter,
  ...AgreemenPrivacyRouter,
  ...AgreemenRegisterRouter,
  // ...OrderDetailsRouter,
  ...RepayRouter,
  ...HelpRouter,
  ...HelpRepaySkyRouter,
  ...HelpRepayMspRouter,
  ...HelpRepayappRouter,
  ...HelpRepaymlRouter,
  ...HelpRepaypartnerRouter,
  ...HelpGetmoneyRouter,
  ...HelpReviewtimeRouter,
  ...HelpLoanproblemRouter,
  ...HelpRepayecpayRouter,
  ...HelpMspRepaymlRouter,
  ...HelpMspRepayrdRouter,
  ...HelpMspRepayecpayRouter,
  ...HelpMspRepayappRouter,
  ...HelpMspGetmoneyRouter,
  ...HelpMspGetmoneyMlRouter,
  ...HelpMspGetmoneyRdRouter,
  ...HelpQuestionRouter,
  ...AboutRouter,
  ...AccountRouter,
  ...ExtensionApplyRouter,
  ...ExtensionApplySuccessRouter,
  ...ExtensionHistoryRouter,
  ...ExtensionDetailsRouter,
  // ...CouponListRouter,
  ...PagesRouter,
  ...Login,
  ...OrderDetailInfo,
  ...doubleDanEvent
];
// if (process.env.NODE_ENV !== 'development') {
//   routes = routes.map(item => {
//     if (item.path !== '/') {
//       item.path = `/:prefix${item.path}/:suffix/:suffix2/:suffix3`;
//     }
//     return item;
//   });
//   Router.prototype.push = function (location, onComplete, onAbort) {
//     // 非本地开发环境的时候，使用随机路由
//     const url = new URL(`${window.location.origin}${typeof location === 'string' ? location : location.path}`);
//     let newLocation = `/${generateRandom()}${url.pathname}/${generateRandom()}/${generateRandom()}/${generateRandom()}}${url.search}`;
//     if (typeof location !== 'string') {
//       newLocation = {
//         ...location,
//         path: newLocation
//       };
//     }
//     this.history.push(newLocation, onComplete, onAbort);
//   };
// }

const router = new Router({
  mode: 'history',
  routes,
});

hooks(router);
Vue.use(Router);
export default router;
